package cn.edu.hust.youth.tzb.servlet.student;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.edu.hust.youth.tzb.dao.TeamDAO;
import cn.edu.hust.youth.tzb.model.Student;

public class Viewteamstudent extends HttpServlet {
	private static final String CONTENT_TYPE = "text/html; charset=GBK";
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		HttpSession session = request.getSession(true);
        response.setContentType(CONTENT_TYPE);
        String act=request.getParameter("act");
        String teamid=request.getParameter("teamid");
        String uid=request.getParameter("uid");
        //System.out.println("viewteam:act="+act+";teamid="+teamid+";uid="+uid);
        TeamDAO td=new TeamDAO();
        Student s=td.getTeamStudent(teamid,uid);
        String target="";
        request.setAttribute("teamstudent", s);
        if(act.endsWith("m")){
        	target = "/student/modifystudentinfo.jsp";
        }else if(act.equals("v")){
        	target = "/student/viewstudentinfo.jsp";
        }
        RequestDispatcher rd = this.getServletContext().getRequestDispatcher(target);
        rd.forward(request,response);
	}

	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}

}
